package com.gxan.service.impl;

import com.gxan.dao.RecruitDao;
import com.gxan.dao.impl.RecruitDaoImpl;
import com.gxan.pojo.Recruit;
import com.gxan.pojo.Resume;
import com.gxan.pojo.SysDept;
import com.gxan.pojo.SysJob;
import com.gxan.service.RecruitService;

import java.sql.SQLException;
import java.util.List;

public class RecruitServiceImpl implements RecruitService {
    private final RecruitDao recruitDao = new RecruitDaoImpl();
    @Override
    public List<Recruit> findAllPosts(Integer page, Integer limit) throws SQLException {

        Integer offset = (page - 1) * limit;
        return recruitDao.findAllPosts(offset,limit);
    }

    @Override
    public Integer countAll() throws SQLException {
        return recruitDao.countAll();
    }

    @Override
    public int delPostById(Integer recruitId) throws SQLException {
        return recruitDao.delPostById(recruitId);
    }

    @Override
    public int updatePost(Recruit recruit) throws SQLException {
        return recruitDao.updatePost(recruit);
    }

    @Override
    public int addPost(Recruit recruit) throws SQLException {
        return recruitDao.addPost(recruit);
    }

    @Override
    public List<Recruit> searchPost(String jobName, String jobType, String time1, String time2, Integer page, Integer limit) throws SQLException {
        Integer offset = (page - 1) * limit;
        return recruitDao.searchPost(jobName,jobType,time1,time2,offset,limit);
    }

    @Override
    public int countSearch(String jobName, String jobType, String time1, String time2) throws SQLException {
        return recruitDao.countSearch(jobName,jobType,time1,time2);
    }

    @Override
    public List<Resume> findAllResume(Integer page, Integer limit) throws SQLException {
        Integer offset = (page - 1) * limit;
        return recruitDao.findAllResume(offset,limit);
    }

    @Override
    public Integer countAllResume() throws SQLException {
        return recruitDao.countAllResume();
    }

    @Override
    public int addResume(Resume resume) throws SQLException {
        return recruitDao.addResume(resume);
    }

    @Override
    public int delResumeById(Integer resumeId) throws SQLException {
        return recruitDao.delResumeById(resumeId);
    }

    @Override
    public List<Resume> findAllInterview(Integer page, Integer limit) throws SQLException {
        Integer offset = (page - 1) * limit;
        return recruitDao.findAllInterview(offset,limit);
    }

    @Override
    public Integer countAllInterview() throws SQLException {
        return recruitDao.countAllInterview();
    }

    @Override
    public List<Resume> findAllHire(Integer page, Integer limit) throws SQLException {
        Integer offset = (page - 1) * limit;
        return recruitDao.findAllHire(offset,limit);
    }

    @Override
    public Integer countAllHire() throws SQLException {
        return recruitDao.countAllHire();
    }

    @Override
    public List<SysJob> getJobName() throws SQLException {
        return recruitDao.getJobName();
    }

    @Override
    public List<SysDept> getDeptName() throws SQLException {
        return recruitDao.getDeptName();
    }

    @Override
    public int updateResume(Resume resume) throws SQLException {
        return recruitDao.updateResume(resume);
    }

    @Override
    public List<Resume> searchResume(String name, String jobName, String experience, String status, String regTime, Integer page, Integer limit) throws SQLException {
        Integer offset = ( page -1 ) * limit;
        return recruitDao.searchResume(name,jobName,experience,status,regTime,offset,limit);
    }

    @Override
    public int countSearchResume(String name, String jobName, String experience, String status, String regTime) throws SQLException {
        return recruitDao.countSearchResume(name,jobName,experience,status,regTime);
    }

    @Override
    public int addInterview(Integer resumeId) throws SQLException {
        return recruitDao.addInterview(resumeId);
    }

    @Override
    public int updateInterview(Resume resume) throws SQLException {
        return recruitDao.updateInterview(resume);
    }

    @Override
    public int addHire(Integer resumeId,Integer interviewId) throws SQLException {
        return recruitDao.addHire(resumeId,interviewId);
    }

    @Override
    public int updateStatus(String status,Integer resumeId) throws SQLException {
        return recruitDao.updateStatus(status,resumeId);
    }

    @Override
    public int updateHire(Resume resume) throws SQLException {
        return recruitDao.updateHire(resume);
    }
}
